function ArduinoUnoBlocks(Blockly) {
    const color = "#FF8C00";

    Blockly.Blocks['huskyLensSenso_init'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 初始化引脚 rx %1 tx %2 直到成功',
                "args0": [                    
                    {
                        "type": "field_dropdown",
                        "name": "rx_pin",
                        "options": [
                            ['2', '2'],
                            ['3', '3'],
                            ['4', '4'],
                            ['5', '5'],
                            ['6', '6'],
                            ['7', '7'],
                            ['8', '8'],
                            ['9', '9'],
                            ['10', '10'],
                            ['11', '11'],
                            ['12', '12'],
                            ['13', '13'],
                            ['A0', 'A0'],
                            ['A1', 'A1'],
                            ['A2', 'A2'],
                            ['A3', 'A3'],
                            ['A4', 'A4'],
                            ['A5', 'A5']
                        ]
                    },
                    {
                        "type": "field_dropdown",
                        "name": "tx_pin",
                        "options": [
                            ['2', '2'],
                            ['3', '3'],
                            ['4', '4'],
                            ['5', '5'],
                            ['6', '6'],
                            ['7', '7'],
                            ['8', '8'],
                            ['9', '9'],
                            ['10', '10'],
                            ['11', '11'],
                            ['12', '12'],
                            ['13', '13'],
                            ['A0', 'A0'],
                            ['A1', 'A1'],
                            ['A2', 'A2'],
                            ['A3', 'A3'],
                            ['A4', 'A4'],
                            ['A5', 'A5']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_setMode'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 切换到 %1 算法 直到成功',
                "args0": [                    
                    {
                        "type": "field_dropdown",
                        "name": "mode",
                        "options": [
                            ['人脸识别', 'ALGORITHM_FACE_RECOGNITION'],
                            ['物体追踪', 'ALGORITHM_OBJECT_TRACKING'],
                            ['物体识别', 'ALGORITHM_OBJECT_RECOGNITION'],
                            ['巡线', 'ALGORITHM_LINE_TRACKING'],
                            ['颜色识别', 'ALGORITHM_COLOR_RECOGNITION'],
                            ['标签识别', 'ALGORITHM_TAG_RECOGNITION'],
                            ['物体分类', 'ALGORITHM_OBJECT_CLASSIFICATION'],
                            ['二维码识别(教育版独有)', 'ALGORITHM_QR_RECOGNITION'],
                            ['条形码识别(教育版独有)', 'ALGORITHM_BARCODE_RECOGNITION']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_request'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 请求一次数据存入结果',
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_readLearnedIDCount'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取已学ID总数',
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_isAppearDirect'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取 %1 是否在画面中？',
                "args0": [                    
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['方框', 'HUSKYLENSResultBlock'],
                            ['箭头', 'HUSKYLENSResultArrow']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_boolean"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_readBlockCenterParameterDirect'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取靠近中心方框的 %1 参数',
                "args0": [
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['ID', 'ID'],
                            ['X中心', 'xCenter'],
                            ['Y中心', 'yCenter'],
                            ['宽度', 'width'],
                            ['高度', 'height']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_readArrowCenterParameterDirect'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取靠近中心箭头的 %1 参数',
                "args0": [
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['ID', 'ID'],
                            ['X起点', 'xOrigin'],
                            ['Y起点', 'yOrigin'],
                            ['X终点', 'xTarget'],
                            ['Y终点', 'yTarget']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_isLearned'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取ID %1 是否已学习？',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    }
                ],
                "colour": color,
                "extensions": ["output_boolean"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_isAppear'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取ID %1 %2 是否在画面中？',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['方框', 'HUSKYLENSResultBlock'],
                            ['箭头', 'HUSKYLENSResultArrow']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_boolean"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_readBlockParameter'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取ID %1 方框的参数 %2',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['X中心', 'xCenter'],
                            ['Y中心', 'yCenter'],
                            ['宽度', 'width'],
                            ['高度', 'height']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_readArrowParameter'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取ID %1 箭头的参数 %2',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['X起点', 'xOrigin'],
                            ['Y起点', 'yOrigin'],
                            ['X终点', 'xTarget'],
                            ['Y终点', 'yTarget']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_readCount'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取 %1 总数',
                "args0": [
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['方框', 'HUSKYLENSResultBlock'],
                            ['箭头', 'HUSKYLENSResultArrow']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_readBlockParameterDirect'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取第 %1 个方框的 %2 参数',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['ID', 'ID'],
                            ['X中心', 'xCenter'],
                            ['Y中心', 'yCenter'],
                            ['宽度', 'width'],
                            ['高度', 'height']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };
    
    Blockly.Blocks['huskyLensSenso_readArrowParameterDirect'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取第 %1 个箭头的 %2 参数',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['ID', 'ID'],
                            ['X起点', 'xOrigin'],
                            ['Y起点', 'yOrigin'],
                            ['X终点', 'xTarget'],
                            ['Y终点', 'yTarget']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_idReadCount'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取ID %1 %2 总数',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['方框', 'HUSKYLENSResultBlock'],
                            ['箭头', 'HUSKYLENSResultArrow']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_idReadBlockParameter'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取ID %1 第 %2 个方框的参数 %3',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "input_value",
                        "name": "no",
                    },
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['X中心', 'xCenter'],
                            ['Y中心', 'yCenter'],
                            ['宽度', 'width'],
                            ['高度', 'height']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_idReadArrowParameter'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 从结果中获取ID %1 第 %2 个箭头的参数 %3',
                "args0": [
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "input_value",
                        "name": "no",
                    },
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['X起点', 'xOrigin'],
                            ['Y起点', 'yOrigin'],
                            ['X终点', 'xTarget'],
                            ['Y终点', 'yTarget']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["output_number"]
            });
        }
    };
    
    Blockly.Blocks['huskyLensSenso_learnOnece'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 自动学习一次ID %1',
                "args0": [                    
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                ],
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_forgetLearn'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 遗忘当前算法的所有数据',
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_writeName'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 设置当前算法ID %1 名称为 %2',
                "args0": [                    
                    {
                        "type": "input_value",
                        "name": "id",
                    },
                    {
                        "type": "input_value",
                        "name": "na",
                    },
                ],
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_writeOSD'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 屏幕叠加显示文字 %1 在 x %2 y %3',
                "args0": [    
                    {
                        "type": "input_value",
                        "name": "na",
                    },                
                    {
                        "type": "input_value",
                        "name": "x",
                    },                
                    {
                        "type": "input_value",
                        "name": "y",
                    },
                ],
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_clearOSD'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 清除屏幕显示的文字',
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_takePhotoToSDCard'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens 触发 %1 保存到SD卡',
                "args0": [
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['拍照', 'takePhotoToSDCard'],
                            ['截屏', 'screenshotToSDCard']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };

    Blockly.Blocks['huskyLensSenso_saveModelToTFCard'] = {
        init: function () {
            this.jsonInit({
                "message0": 'HuskyLens %1 当前算法数据为SD卡 %2 号模型',
                "args0": [
                    {
                        "type": "field_dropdown",
                        "name": "type",
                        "options": [
                            ['拍照', 'takePhotoToSDCard'],
                            ['截屏', 'screenshotToSDCard']
                        ]
                    },
                    {
                        "type": "field_dropdown",
                        "name": "no",
                        "options": [
                            ['0', '0'],
                            ['1', '1'],
                            ['2', '2'],
                            ['3', '3'],
                            ['4', '4']
                        ]
                    }
                ],
                "colour": color,
                "extensions": ["shape_statement"]
            });
        }
    };


    return Blockly;
}

module.exports = ArduinoUnoBlocks;

